<?php

class Core_Array {
	
	private $_data;
	
	public function __construct($array, $recursive=true) {
		if ($recursive) {
			foreach ($array as $key => $value) {
				if (is_array($value)) {
					$array[$key] = new Core_Array($value, true);
				}
			}
		}
		$this->_data = $array;
	}
	
	public function set($key, $value) {
		$this->_data[$key] = $value;
	}
	
	public function add($value) {
		$this->_data[] = $value;
	}
	
	public function get($key, $default=null) {
		return (key_exists($key, $this->_data)) ? $this->_data[$key] : $default;
	}
	
	public function __get($key) {
		return $this->get($key);
	}
	
	public function __set($key, $value) {
		$this->set($key, $value);
	}
	
}